package com.mashibing.controller;

import com.mashibing.dto.ResponseResult;
import com.mashibing.dto.TokenResult;
import com.mashibing.service.UserService;
import com.mashibing.util.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 查询乘客基本信息
     * 1、获取token  解析手机号
     * 2、通过手机号在数据库中查找信息
     * @param httpServletRequest
     * @return
     */
    @GetMapping("/users")
    public ResponseResult getUserInfo(HttpServletRequest httpServletRequest){

        String accessToken = httpServletRequest.getHeader("Authorization");

        ResponseResult result = userService.getUserInfo(accessToken);
        return result;
    }
}
